export function deepClone(obj) {
  if (obj === null) return null
  if (typeof obj !== 'object') return obj
  if (obj instanceof RegExp) {
    return new RegExp(obj)
  }

  if (obj instanceof Date) {
    return new Date(obj)
  }

  const newObj = new obj.constructor()
  for (const k in obj) {
    if (Object.prototype.hasOwnProperty.call(obj, k)) {
      newObj[k] = deepClone(obj[k])
    }
  }
  return newObj
}
